import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from './modules/home'
import News from './modules/news'
import Safe from './modules/safe'
import My from './modules/my'

Vue.use(VueRouter)
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register')
  },
  {
    path: '/',
    // name: 'layout',
    component: () => import('@/views/Layout'),
    children: [
      Home,
      News,
      Safe,
      My
    ]
  },
  {
    path: '/contact',
    name: 'contact',
    component: () => import('@/views/My/components/contact')
  },
  {
    path: '/info',
    name: 'info',
    component: () => import('@/views/My/components/info')
  },
  {
    path: '/test',
    name: 'test',
    component: () => import('@/views/Safe/test.vue')
  },
  {
    path: '/examination',
    name: 'examination',
    component: () => import('@/views/Safe/examination.vue')
  },
  {
    path: '/Practice',
    name: 'Practice',
    component: () => import('@/views/Safe/Practice.vue')
  },
  {
    path: '/PracticeALL',
    name: 'PracticeALL',
    component: () => import('@/views/Safe/PracticeALL.vue')
  },
  {
    path: '/safelook',
    name: 'safelook',
    component: () => import('@/views/Home/components/SafeLook.vue')
  },
  {
    path: '/detail/:id',
    name: 'detail',
    component: () => import('@/views/Home/detail/index.vue')
  },
  {
    path: '/feedback',
    name: 'feedback',
    component: () => import('@/views/My/components/feedback')
  },
  {
    path: '/setting',
    name: 'setting',
    component: () => import('@/views/My/components/setting')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/Home/search/index.vue')
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404')
  },
  { path: '*', redirect: '/404', hidden: true }
]

const router = new VueRouter({
  routes
})

router.onError((err) => {
  console.log(err, 'hehe')
})

export default router
